<?php
require_once "../funciones.php";

$caweb = con_caweb();
?>

<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link type="text/css" href="../css/redmond/jquery-ui-1.8.2.custom.css" rel="stylesheet" />
        <link rel="stylesheet" type="text/css" media="screen" href="../css/ui.jqgrid.css" />
        <link rel="stylesheet" type="text/css" media="screen" href="../css/ui.multiselect.css" />
        <script src="../js/jquery.js" type="text/javascript"></script>
        <script src="../js/jquery-ui-1.8.2.custom.min.js" type="text/javascript"></script>
        <script src="../js/i18n/grid.locale-sp.js" type="text/javascript"></script>
        <script src="../js/jquery.jqGrid.min.js" type="text/javascript"></script>
        <script src="../js/ui.multiselect.js" type="text/javascript"></script>
        <title></title>
        <script>
            jQuery(document).ready(function(){
                var buscar = $("#buscar");
                var urla = "hola";
                $("#fecIni").datepicker({dateFormat:"yy-mm-dd"});
                $("#fecFin").datepicker({dateFormat:"yy-mm-dd"});
                jQuery("#multiple37").jqGrid({
                    url:urla,
                    datatype: "json",
                    colNames:['Item','OC','Fecha','Cantidad','Proveedor','Valor','Sucursal'],
                    colModel:[
                        {name:'item',index:'item', width:305},
                        {name:'oc',index:'oc', width:130,align: 'center',edittype:'select', editoptions:{value:":All;0.00:0.00;12:12.00;20:20.00;40:40.00;60:60.00;120:120.00"}},
                        {name:'fecha',index:'fecha', width:180, editrules:{date:true}, align: 'center'},
                        {name:'cantidad',index:'cantidad', width:150, align: 'center'},
                        {name:'proveedor',index:'proveedor', width:600},
                        {name:'valor',index:'valor', width:300,align: 'right',formatter:'currency'},
                        {name:'sucursal',index:'sucursal', width:150,align: 'center'}
                    ],
                    rowNum:50,
                    rowTotal: 2000,
                    rowList : [20,30,50],
                    loadonce:true,
                    mtype: "GET",
                    rownumbers: true,
                    rownumWidth: 40,
                    gridview: true,
                    pager: '#pmultiple37',
                    sortname: 'item',
                    viewrecords: true,
                    sortorder: "asc",
                    caption: "ORDENES DE COMPRA",
                    height: '80%'
                });

        buscar.click(function(){

            urla = "fecIni=" + $("#fecIni").val() + "\&fecFin=" + $("#fecFin").val() + "\&prove=" + $("#prove").val();
            jQuery("#multiple37").jqGrid('setGridParam',{url:"scpconsultaCompras.php?" + urla}).trigger("reloadGrid");
        });

                jQuery("#multiple37").jqGrid('navGrid','#pmultiple37',{del:false,add:false,edit:false},{},{},{},{multipleSearch:true});
            }); //fin ready
        </script>
    </head>
    <body>
        <center>
        <table>
            <caption>
                CONSULTA DE ORDENES DE COMPRA
            </caption>
            <tr>
                <td><label for="fecIni">Fecha Inicial</label></td>
                <td><input type="text" name="fecIni" id="fecIni" size="8" /></td>
                <td><label for="fecFin">Fecha Final</label></td>
                <td><input type="text" name="fecFin" id="fecFin" size="8" /></td>
            </tr>
            <tr>
                <td><label for="prove">Proveedor</label></td>
                <td colspan="3">
                    <select name="prove" id="prove">
                        <option value="">Todos</option>
                        <?php
                        $sql = "select * from proveedores order by nombre";
                        $result = mysql_query($sql,$caweb);
                        while ($prove = mysql_fetch_array($result)) {
                            echo "<option value='".$prove[nit]."'>$prove[nombre]</option>";
                        }
                        ?>
                    </select>
                </td>
            </tr>
            <tr align="center">
                <td colspan="4">
                    <input type="button" value="Buscar" id="buscar"/>
                    <input type="button" value="Nuva Busqueda" onclick="location.reload()" />
                </td>
            </tr>
        </table>
            <div id="grilla" style="display: block;">
        <table id="multiple37"></table>
        <div id="pmultiple37" ></div>
        </div>
        </center>
    </body>
</html>
